/*
 * MIT License
 *
 * Copyright (c) 2020 wen.gu <454727014@qq.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/***************************************************************************
 * Name: initialization.h
 *
 * Purpose: This section describes the global initialization and shutdown 
 *          functions that initialize resp. deinitialize data structures and 
 *          threads of the AUTOSAR Runtime for Adaptive
Applications
 *
 * Developer:
 *   wen.gu , 2020-04-20
 *
 * TODO:
 *
 ***************************************************************************/

#ifndef __ARA_CORE_INITIALIZATION_H__
#define __ARA_CORE_INITIALIZATION_H__
/******************************************************************************
 **    INCLUDES
 ******************************************************************************/

#include "ara/core/result.h"
/******************************************************************************
 **    MACROS
 ******************************************************************************/


/******************************************************************************
 **    TYPE DEFINITIONS
 ******************************************************************************/
namespace ara
{
namespace core
{
/******************************************************************************
 **    CLASSES/FUNCTIONS DEFINITIONS
 ******************************************************************************/
/**
 * Initializes data structures and threads of the AUTOSAR Adaptive Runtime for Applications.
 * Prior to this call, no interaction with the ARA is possible. This call must be made inside of
 * main(), i.e., in a place where it is guaranteed that static memory initialization has completed.
 * Depending on the individual functional cluster specification, the calling application may have to
 * provide additional configuration data (e.g., set an Application ID for Logging) or make additional
 * initailization calls (e.g., start a FindService in ara::com) before other API calls to the respective
 * functional cluster can be made. Such calls must be made after the call to Initialize(). Calls to
 * ARA APIs made before static initialization has completed lead to undefinded behavior. Calls
 * made after static initialization has completed but before Initialize() was called will be rejected by
 * the functional cluster implementation with an error or, if no error to be reported is defined, lead
 * to undefined behavior.
 *
 * Result<void> : A Result object that indicates whether the
 *                AUTOSAR Adaptive Runtime for Applications was
 *                successfully initialized. Note that this is the only way
 *                for the ARA to report an error that is guaranteed to
 *                be available, e.g., in case ara::log failed to correctly
 *                initialize. The user is not expected to be able to
 *                recover from such an error. However, the user may
 *                have a project-specific way of recording errors
 *                during initialization without ara::log.
 */


Result<void> Initialize();

/**
 * Destroy all data structures and threads of the AUTOSAR Adaptive Runtime for Applications.
 * After this call, no interaction with the ARA is possible. This call must be made inside of main(),
 * i.e., in a place where it is guaranteed that the static initialization has completed and destruciton
 * of statically initialized data has not yet started. Calls made to ARA APIs after a call to
 * ara::core::Deinitialize() but before destruction of statically initialized data will be rejected with an
 * error or, if no error is defined, lead to undefined behavior. Calls made to ARA APIs after the
 * destruction of statically initialized data will lead to undefined behavior.
 *
 * Result<void>: A Result object that indicates whether the ARA was
 *               successfully destroyed. Typical error cases to be
 *               reported here are that the user is still holding some
 *               resource inside the ARA. Note that this Result is the
 *               only way for the ARA to report an error that is
 *               guaranteed to be available, e.g., in case ara::log has
 *               already been deinitialized. The user is not expected
 *               to be able to recover from such an error. However,
 *               the user may have a project-specific way of
 *               recording errors during deinitialization without
 *               ara::log
 */
Result<void> Deinitialize();


} /** namespace core */
} /** namespace ara */

#endif /** !__ARA_CORE_INITIALIZATION_H__ */

